<html>
  <head>
    <title>TestNG - Welcome</title>
      <link rel="stylesheet" href="testng.css" type="text/css" />
      <link type="text/css" rel="stylesheet" href="http://beust.com/beust.css"  />
      <script type="text/javascript" src="http://beust.com/prettify.js"></script>
      <script type="text/javascript" src="banner.js"></script>

      <script type="text/javascript" src="http://beust.com/scripts/shCore.js"></script>
      <script type="text/javascript" src="http://beust.com/scripts/shBrushJava.js"></script>
      <script type="text/javascript" src="http://beust.com/scripts/shBrushXml.js"></script>
      <script type="text/javascript" src="http://beust.com/scripts/shBrushBash.js"></script>
      <script type="text/javascript" src="http://beust.com/scripts/shBrushPlain.js"></script>
      <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shCore.css"/>
      <link type="text/css" rel="stylesheet" href="http://beust.com/styles/shThemeCedric.css"/>
      <script type="text/javascript">
        SyntaxHighlighter.config.clipboardSwf = 'scripts/clipboard.swf';
        SyntaxHighlighter.defaults['gutter'] = false;
        SyntaxHighlighter.all();
      </script>

    </head>

<body onload="prettyPrint()">

<script type="text/javascript">
   displayMenu("index.html");
</script>


<h2 >TestNG</h2>
<h2>Now available</h2>
<p align="center">
<a href="book.html">
<img border="0" src="http://beust.com/pics/book-cover.jpg" />
</a>
</p>
<p align="center">
<a href="book.html">Click for more details.</a>
</p>



<p align="right"><font size="-2"><em>C&eacute;dric Beust (cedric at beust.com)<br>
Current version: 6.9.10<br>
Created:&nbsp;April 27th, 2004<br>
Last Modified:&nbsp; December 19th, 2015</em></font></p>


<p>TestNG is a testing framework inspired from JUnit and NUnit but introducing
some new functionalities that make it more powerful and easier to use, such as:</p>
<ul>
       <li>Annotations.
       </li>
       <li>Run your tests in arbitrarily big thread pools with various policies available
       (all methods in their own thread, one thread per test class, etc...).
       </li>
       <li>Test that your code is multithread safe.
       </li>
       <li>Flexible test configuration.
       </li>
       <li>Support for data-driven testing (with <tt>@DataProvider</tt>).
       </li>
       <li>Support for parameters.
       </li>
       <li>Powerful execution model (no more <tt>TestSuite</tt>).
       </li>
       <li>Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven,
       etc...).
       </li>
       <li>Embeds BeanShell for further flexibility.
       </li>
       <li>Default JDK functions for runtime and logging (no dependencies).
       </li>
       <li>Dependent methods for application server testing.</li>
</ul>
<p>TestNG is designed to cover all categories of tests:&nbsp; unit, functional,
end-to-end, integration, etc...</p>
<p>I started TestNG out of frustration for some JUnit deficiencies which I have
documented on my weblog <a href="http://beust.com/weblog/2004/08/25/testsetup-and-evil-static-methods/">here</a> and <a href="http://beust.com/weblog/2004/02/08/junit-pain/">here</a>
Reading these entries might give you a better idea of the goal I am trying to
achieve with TestNG.&nbsp; You can also check out a quick
<a href="http://www.beust.com/weblog/archives/000176.html">overview of the main
features</a> and an <a href="http://beust.com/weblog/2004/08/18/using-annotation-inheritance-for-testing/">
article</a> describing a very concrete example where the combined use of several
TestNG's features provides for a very intuitive and maintainable testing design.</p>
<p>Here is a very simple test:</p>

<h3 class="sourcetitle">SimpleTest.java</h3>
<pre class="brush: java" >
package example1;

import org.testng.annotations.*;

public class SimpleTest {

 @BeforeClass
 public void setUp() {
   // code that will be invoked when this test is instantiated
 }

 @Test(groups = { "fast" })
 public void aFastTest() {
   System.out.println("Fast test");
 }

 @Test(groups = { "slow" })
 public void aSlowTest() {
    System.out.println("Slow test");
 }

}
</pre>

The method <tt>setUp()</tt> will be invoked after the test class has been built and before
any test method is run.&nbsp; In this example, we will be running the group
fast, so <tt>aFastTest()</tt> will be invoked while <tt>aSlowTest()</tt> will be
skipped.<p>
<!-------------------------------------

 WRITING A TEST

 ------------------------------------>

Things to note:</p><ul>
       <li>No need to extend a class or implement an interface.</li><li>Even though the example above uses the JUnit conventions, our methods
       can be called any name you like, it's the annotations that tell TestNG what
       they are.</li><li>A test method can belong to one or several groups.</li></ul>

       <p>

Once you have compiled your test class into the <tt>build</tt> directory, you
can invoke your test with the command line, an ant task (shown below) or an XML
file:

<h3 class="sourcetitle">build.xml</h3>
<pre class="brush:java">
&lt;project default="test"&gt;

 &lt;path id="cp"&gt;
   &lt;pathelement location="lib/testng-testng-5.13.1.jar"/&gt;
   &lt;pathelement location="build"/&gt;
 &lt;/path&gt;

 &lt;taskdef name="testng" classpathref="cp"
          classname="org.testng.TestNGAntTask" /&gt;

 &lt;target name="test"&gt;
   &lt;testng classpathref="cp" groups="fast"&gt;
     &lt;classfileset dir="build" includes="example1/*.class"/&gt;
   &lt;/testng&gt;
 &lt;/target&gt;

&lt;/project&gt;
</pre>

Use ant to invoke it:

<pre class="brush: text">
c:&gt; ant
Buildfile: build.xml

test:
[testng] Fast test
[testng] ===============================================
[testng] Suite for Command line test
[testng] Total tests run: 1, Failures: 0, Skips: 0
[testng] ===============================================


BUILD SUCCESSFUL
Total time: 4 seconds
</pre>

Then you can browse the result of your tests:

<pre class="brush: text">
start test-output\index.html (on Windows)
</pre>

<h3><a name="requirements">Requirements</a></h3>
<p>TestNG requires JDK 7 or higher.</p>

<h3><a name="mailing-lists">Mailing-lists</a></h3>

<ul>
<li>The users mailing-list can be found on <a href="http://groups.google.com/group/testng-users">Google Groups</a>.
<li>If you are interested in working on TestNG itself, join the <a href="http://groups.google.com/group/testng-users">developer mailing-list</a>.
<li>If you are only interested in hearing about new versions of TestNG, you can join the low volume <a href="http://groups.google.com/group/testng-announcements">TestNG announcement mailing-list</a>.
</ul>


<h3><a name="locations-projects">Locations of the projects</a></h3>
<p>If you are interested in contributing to TestNG or one of the IDE plug-ins,
you will find them in the following locations:</p>
<ul>
       <li><a href="http://github.com/cbeust/testng/">TestNG</a></li>
       <li><a href="http://github.com/cbeust/testng-eclipse/">Eclipse plug-in</a></li>
<!--
       <li><a href="http://code.google.com/p/testng/">TestNG</a></li>
       <li><a href="http://code.google.com/p/testng-eclipse">Eclipse plug-in</a></li>
-->
      <li><a href="https://github.com/JetBrains/intellij-community/tree/master/plugins/testng">IDEA IntelliJ plug-in</a></li>
       <li><a href="http://wiki.netbeans.org/TestNG">NetBeans plug-in</a></li>
</ul>
<h3><a id="bug-reports" name="bug-reports">Bug reports</a></h3>

If you think you found a bug, here is how to report it:

<ul>
<li>Create a small project that will allow us to reproduce this bug. In most cases, one or two Java source files and a <tt>testng.xml</tt> file should be sufficient. Then you can either zip it and email it to the <a href="http://groups.google.com/group/testng-dev">testng-dev mailing-list</a> or make it available on an open source hosting site, such as <a href="http://github.com">github</a> or <a href="http://code.google.com/hosting/">Google code</a> and email <tt>testng-dev</tt> so we know about it. Please make sure that this project is self contained so that we can build it right away (remove the dependencies on external or proprietary frameworks, etc...).

<li>If the bug you observed is on the Eclipse plug-in, make sure your sample project contains the <tt>.project</tt> and <tt>.classpath</tt> files.

<li><a href="https://github.com/cbeust/testng/issues">File a bug</a>.

</ul>

</p>

<p>For more information, you can either <a href="download.html">download TestNG</a>, read the <a href="documentation-main.html">manual</a> or browse the links at the<a href="#top">top</a>.</p>

<h3>License</h3>

<a href="http://testng.org/license">Apache 2.0</a>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-238215-2";
urchinTracker();
</script>


</body>

</html>

